package com.xueyi.workflow.convert;

import com.xueyi.common.core.web.entity.model.BaseConverter;
import com.xueyi.workflow.domain.query.WfProcessApprovalQuery;
import com.xueyi.workflow.domain.dto.WfProcessApprovalDto;
import com.xueyi.workflow.domain.entity.WfProcessApproval;
import com.github.pagehelper.Page;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

@Component
public class WfProcessApprovalConverter implements BaseConverter<WfProcessApprovalQuery, WfProcessApprovalDto, WfProcessApproval> {
    @Override
    public WfProcessApprovalDto mapperDto(WfProcessApproval po) {
        if (po == null) return null;
        WfProcessApprovalDto dto = new WfProcessApprovalDto();
        BeanUtils.copyProperties(po, dto);
        return dto;
    }
    @Override
    public List<WfProcessApprovalDto> mapperDto(Collection<WfProcessApproval> poList) {
        if (poList == null) return null;
        return poList.stream().map(this::mapperDto).collect(Collectors.toList());
    }
    @Override
    public Page<WfProcessApprovalDto> mapperPageDto(Collection<WfProcessApproval> poList) {
        // 如有分页需求可实现
        return null;
    }
    @Override
    public WfProcessApproval mapperPo(WfProcessApprovalDto dto) {
        if (dto == null) return null;
        WfProcessApproval po = new WfProcessApproval();
        BeanUtils.copyProperties(dto, po);
        return po;
    }
    @Override
    public List<WfProcessApproval> mapperPo(Collection<WfProcessApprovalDto> dtoList) {
        if (dtoList == null) return null;
        return dtoList.stream().map(this::mapperPo).collect(Collectors.toList());
    }
    @Override
    public Page<WfProcessApproval> mapperPagePo(Collection<WfProcessApprovalDto> dtoList) {
        // 如有分页需求可实现
        return null;
    }
} 